﻿@model equinoxWeb.Models.Caso
@{
    ViewBag.Title = "Editar caso";
    Layout = (ViewBag.esCliente!=null && ViewBag.esCliente?"~/Views/Shared/_ClienteLayout.cshtml":"~/Views/Shared/_Layout.cshtml");
}
@using equinoxWeb.Models;
<!-- content -->
<script>
    $(function () {
        $("#ETA").datepicker();
        $("#FechaNominacion").datepicker();
        $("#FechaInicio").datepicker();
        $("#FechaFin").datepicker();
    });
</script>
<script src="/Scripts/caso.js"></script>
<script src="/Scripts/cliente.js"></script>


<form class="form-horizontal" name="editForm" method="post">
    <fieldset>
        <legend>Editar caso</legend>
        <div class="form-group @(ViewBag.error == null || ViewBag.error == "" ?"":"has-error")">
            <label class="control-label" style="display:@(ViewBag.error == null || ViewBag.error == "" ?"none":"inline")">@(ViewBag.error == null || ViewBag.error == "" ?"":ViewBag.error)</label>
        </div>
        @Html.HiddenFor(model => model.IdCaso)
        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="NReferencia">Número de referencia:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.NReferencia, new { @class = "form-control" })
            </div>
        </div>
		@if (@ViewBag.listaAnhos!=null){
        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Anho">Año de ejecución:</label>
            <div class="col-md-3 col-sm-6">
                <select class = "form-control" name="Anho">
                    @foreach (int anho in @ViewBag.listaAnhos)
                    {
                        <option value="@anho">@anho</option>
                    }
                </select>
            </div>
        </div>
		}

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Cliente.IdCliente">Cliente:</label>
            <div class="col-md-3 col-sm-6">
                <select name="Cliente.IdCliente" id="IdCliente" onchange="javascript:obtenerClub();"  class="form-control">
                    @foreach (Cliente cliente in ViewBag.listaCliente)
                    {
                        <option value="@cliente.Idcliente" @(cliente.Idcliente == Model.Cliente.Idcliente ? "selected" : "") >@cliente.RazonSocial</option>
                    }
                </select>
            </div>
        </div>

        <div class="form-group" id="divClub" style="display:none">
            <label class="col-md-4 col-sm-6 control-label" for="Cliente.IdCliente">Club:</label>
            <div class="col-md-3 col-sm-6">
                <select name="Club.IdClub" id="idClub" class="form-control">
                </select>
            </div>
        </div>
        <input type="hidden" id="indiceClub" value="@(Model.Club != null ? Model.Club.IdClub + "" : "0")">

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Inspector">Inspector:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.Inspector, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Location">Ubicación:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.Location, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Ship">Nave:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.Ship, new { @class = "form-control" })
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Agente">Agente:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.Agente, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Ruc">Contenido:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextAreaFor(model => model.Content, new { @class = "form-control" })
            </div>
        </div>
        
        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="ClubPandI">Club PandI:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextAreaFor(model => model.ClubPandI, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Observaciones">Observaciones:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextAreaFor(model => model.Observaciones, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="ETA">ETA:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.ETA, new { @class = "form-control", id = "ETA", placeholder = "DD/MM/YYYY" })
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="FechaNominacion">Fecha de nominación:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.FechaNominacion, new { @class = "form-control", id = "FechaNominacion", placeholder = "DD/MM/YYYY" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="FechaInicio">Fecha de inicio:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.FechaInicio, new { @class = "form-control", id = "FechaInicio", placeholder = "DD/MM/YYYY" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="FechaFin">Fecha de fin programada:</label>
            <div class="col-md-3 col-sm-6">
                @Html.TextBoxFor(model => model.FechaFin, new { @class = "form-control", id = "FechaFin", placeholder = "DD/MM/YYYY" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="TipoCaso.IdTipoCaso">Tipo de caso:</label>
            <div class="col-md-3 col-sm-6">
                <select name="TipoCaso.IdTipoCaso" class="form-control">
                    @foreach (TipoCaso tipoCaso in ViewBag.listaTipoCaso)
                    {
                        <option value="@tipoCaso.IdTipoCaso" @(tipoCaso.IdTipoCaso == Model.TipoCaso.IdTipoCaso ? "selected" : "") >@tipoCaso.Descripcion</option>
                    }
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-4 col-sm-6 control-label" for="Usuario.IdUsuario">Encargado del caso:</label>
            <div class="col-md-3 col-sm-6">
                <select name="Usuario.IdUsuario" class="form-control">
                    @foreach (Usuario usuario in ViewBag.listaUsuario)
                    {
                        <option value="@usuario.IdUsuario"  @(usuario.IdUsuario == Model.Usuario.IdUsuario ? "selected" : "") >@(usuario.Nombre + " " + usuario.ApellidoPat)</option>
                    }
                </select>
            </div>
        </div>
        <input type ="hidden" value ="@Constantes.EstadoAbierto" name ="EstadoCaso.IdEstadoCaso" />
        <br />
        <div class="form-group">
            <div class="col-md-3 col-sm-6">
                <button type="button" onclick="ModificarCaso(editForm)" class="btn btn-large btn-primary">Grabar</button>&nbsp;
                <button type="button" class="btn btn-large" onclick="javascript:history.back();">Atras</button>
            </div>
        </div>


    </fieldset>
</form>
<!-- / content -->

<script>
    obtenerClub();

</script>